#===============================================================================
# Koro Business Environment
# Copyright (C) 2008  Antonio Corroppoli
#
#This file is part of Koro BE.
# 
# Koro BE is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# Koro BE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Koro BE; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#===============================================================================
class KoroException(Exception):
    """ Base class in the framework for passing exceptions."""
    def __init__(self,err):
        Exception.__init__(self,err)

class KoroError(Exception):
    """ Base class in the framework for passing error."""
    def __init__(self,err):
        Exception.__init__(self,err)

class KoroInternalError(KoroError):
    def __init__(self,err):
        KoroError.__init__(self,err)

class KoroValidationError(KoroError):
    def __init__(self,err):
        KoroError.__init__(self,err)

class KoroInvalidObject(KoroException):
    def __init__(self,err):
        KoroException.__init__(self,err)

class KoroIncompleteObject(KoroException):
    def __init__(self,err,obj,missing):
        KoroException.__init__(self,err)
        self.object=obj
        self.missing=missing

class KoroDuplicatedObject(KoroException):
    def __init__(self,err):
        KoroException.__init__(self,err)

class KoroIntegrityError(KoroError):
    def __init__(self,params, orig):
        KoroError.__init__(self,orig[1])
        self.param=params        
        
class KoroLockError(KoroError):
    def __init__(self,err):
        KoroError.__init__(self,err)

class KoroContextError(KoroError):
    def __init__(self,err):
        KoroError.__init__(self,err)

class KoroModuleException(KoroException):
    def __init__(self,err):
        KoroException.__init__(self,err)

class KoroDatabaseException(KoroException):
    def __init__(self,err):
        KoroException.__init__(self,err)        

class KoroDBTypeException(KoroDatabaseException):
    def __init__(self,err):
        KoroDatabaseException.__init__(self,err)

class KoroDBNoAccessException(KoroDatabaseException):
    def __init__(self,err):
        KoroDatabaseException.__init__(self,err)
    
class KoroDBNoDBOnHostException(KoroDatabaseException):
    def __init__(self,err):
        KoroDatabaseException.__init__(self,err)

class KoroDBOperationException(KoroDatabaseException):
    def __init__(self,err):
        KoroDatabaseException.__init__(self,err)

class KoroDBQueryException(KoroDatabaseException):
    def __init__(self, err, sql):        
        KoroDatabaseException.__init__(self,err)
        self.sql = sql
        self.err_desc = str(err)
        
    def __str__(self):
        return self.err_desc + '\nSQL: ' + self.sql

